﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using PUZZLEgestServer.DTO;

using NLog;

namespace PUZZLEgestServer.SVC
{
    public class Login : ILogin
    {
        Logger logger = LogManager.GetCurrentClassLogger();

        public bool IsFirstLogin()
        {
            logger.Info("IsFirstLogin");

            //check if there is another user on this db that is not the super admin user
            string query = "select uid from sysusers where issqluser = @issqluser and hasdbaccess = @hasdbaccess and name <> @superadmin";

            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(DAL.DataAccess.SuperAdminConnectionString);
            conn.Open();
            System.Data.DataTable dt=  DAL.DataAccess.Select(conn, query,
                new System.Data.SqlClient.SqlParameter("issqluser",1),
                new System.Data.SqlClient.SqlParameter("hasdbaccess",1),
                new System.Data.SqlClient.SqlParameter("superadmin",Util.Globals.ReadRegistryKey("user", true))
                );

            if (dt == null || (dt != null && dt.Rows.Count == 0))
                return true;
            else
                return false;
        }

        public DAL.User LoginPassword(string user, string password) 
        {
            return null;
        }

        public DAL.User LoginPattern(string user, string pattern)
        {
            return null;
        }

        public DAL.User LoginMagneticCard(string user, string cardCode)
        {
            return null;
        }

    }
}
